package com.itheima.reggie.mapper;

import com.itheima.reggie.dto.SetmealDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface SetMealMapper {
    @Select("select count(*) from setmeal where category_id =#{id}")
    Integer findByCid(long cid);
    //新增套装
    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    Integer save(SetmealDto setmealDto);

    //根据动态条件name查询所有套餐列表，返回封装到SetmealDto
    List<SetmealDto>findAllByName(@Param("name") String name);
    //根据套餐id列表数据查询启用套餐的个数
    Integer findStatusByIds(@Param("ids") List<Long>ids);

    //根据套餐id列表批量删除停用的数据
    Integer deleteBatch(@Param("ids") List<Long>ids,
                        @Param("opr") Long opr,
                        @Param("updateTime") LocalDateTime updateTime);


    void updateStatusFById(@Param("ids") List<Long>ids,
                           @Param("opr") Long opr,
                           @Param("updateTime") LocalDateTime updateTime);

    void updateStatusTById(@Param("ids") List<Long>ids,
                           @Param("opr") Long opr,
                           @Param("updateTime") LocalDateTime updateTime);


}
